<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html"; charset="UTF-8">
    <title>管理员登录</title>
    <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
</head>
<body>
    管理员登录
    <br>
    <span style="color: red" th:text="${message}"></span>
    <br>
    <form name="loginForm" method="post" th:action="@{/postTicket}">
        账号：
        <input type="text" name="adminName" required="required" placeholder="请输入">
        <br>
        密码：
        <input type="password" name="password" required="required" placeholder="请输入">
        <br>
        <input type="hidden" name="ticket" value="">
        <input type="hidden" name="randstr" value="">
        <input type="button" value="登录" onclick="captcha()">
        <br>
    </form>
</body>
<script>
    captcha = function() {
        if (document.loginForm.adminName.value == ""){
            alert("请输入账号")
            document.loginForm.adminName.focus();
            return false;
        }
        if (document.loginForm.password.value == ""){
            alert("请输入密码")
            document.loginForm.password.focus();
            return false;
        }
        var captcha = new TencentCaptcha('2072922296', function(res) {
            console.log(res)
            if (res.ret === 0){
                document.loginForm.ticket.value = res.ticket;
                document.loginForm.randstr.value = res.randstr;
                document.loginForm.submit();
            }
        });
        captcha.show();
    }
</script>
</html>